package com.itheima.demo1;

import java.util.Random;
import java.util.Scanner;

public class demo1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Random r = new Random();
        int number = r.nextInt(100)+1;
        int cnt=0;
        while (true){
            System.out.println("请输入要猜的数字：");
            int num = sc.nextInt();
            cnt++;
            if(num > number){
                System.out.println("大了");
            } else if (num<number) {
                System.out.println("小了");
            }else{
                System.out.println("恭喜你猜中了");
                System.out.println("总共猜了"+cnt+"次");
                break;
            }
        }
    }
}
